Skip to content

Multi Team: Automatically create and assign team default pools#69768

Open
SameerMesiah97 wants to merge 4 commits into
apache:mainfrom
SameerMesiah97:Multi-Team-Default-Team-Pool
Open

Multi Team: Automatically create and assign team default pools#69768
SameerMesiah97 wants to merge 4 commits into
apache:mainfrom
SameerMesiah97:Multi-Team-Default-Team-Pool

Conversation

@SameerMesiah97

@SameerMesiah97 SameerMesiah97 commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Description

This change introduces automatic default pool management for multi-team deployments.

With this implementation, a corresponding default pool named default_pool_<team_name> is automatically created on team creation. During DAG parsing, tasks that do not explicitly specify a pool are assigned to their team's default pool based on the DAG bundle association, while tasks with explicitly configured pools are left unchanged.

The implementation also extends the team management commands so that teams sync reconciles missing default team pools for existing teams, and teams delete automatically removes the system-managed default team pool.

Rationale

In multi-team deployments, tasks without an explicit pool are currently assigned to the global default_pool, allowing one team's workload to consume capacity shared across all teams. Avoiding this requires users to manually create and configure team-specific pools and update every task to reference them.

By automatically provisioning a per-team default pool and applying it during DAG parsing, Airflow provides sensible defaults while preserving explicit pool assignments. This reduces operational overhead and helps isolate execution capacity between teams without requiring changes to existing DAGs.

Tests

Added unit tests verifying that:

  • Tasks using default_pool are assigned to the appropriate team default pool during DAG parsing.
  • Tasks with explicitly configured pools are not modified.
  • DAGs without an associated team continue to use default_pool.
  • Creating a team automatically provisions its corresponding default pool.
  • teams sync recreates missing default team pools for existing teams.
  • Deleting a team automatically removes its default team pool.
  • Team default pool names are generated correctly.

Documentation

Updated the multi-team documentation to describe automatic creation of team default pools and how they are applied during DAG parsing.

Backwards Compatibility

Existing behaviour is preserved when multi-team mode is disabled. Tasks with explicitly configured pools continue to use their configured pool without modification.

Closes: #69170

Comment thread airflow-core/src/airflow/dag_processing/dagbag.py
@SameerMesiah97
SameerMesiah97 marked this pull request as draft July 12, 2026 16:42
Comment thread airflow-core/src/airflow/models/pool.py
@SameerMesiah97
SameerMesiah97 force-pushed the Multi-Team-Default-Team-Pool branch from 9691842 to fdcf3d6 Compare July 18, 2026 19:18
@SameerMesiah97
SameerMesiah97 marked this pull request as ready for review July 18, 2026 20:05
Comment thread airflow-core/tests/unit/cli/commands/test_team_command.py Outdated
@SameerMesiah97
SameerMesiah97 force-pushed the Multi-Team-Default-Team-Pool branch from fdcf3d6 to 9572e56 Compare July 18, 2026 21:54
@SameerMesiah97

Copy link
Copy Markdown
Contributor Author

@o-nikolas @ferruzzi

Tagging you here as this is your domain i.e. multi-team.

Comment thread airflow-core/src/airflow/cli/commands/team_command.py Outdated
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 20, 2026
):
associations.append(f"{pool_count} pool(s)")

default_pool = session.scalar(select(Pool).where(Pool.pool == Pool.get_default_team_pool_name(team.name)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an edge case but could be named default_pool_marketing and be global. We should check that the pool is also associated to the team

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And additional check has been added to the where clause to ensure that the select pool is associated with the team.

@o-nikolas o-nikolas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! The code needs a fair amount of work but I like the idea!

The specified team must exist in the database (create it first with ``airflow teams create``).

When ``core.multi_team`` is enabled, ``airflow teams create`` automatically
creates a default pool named ``default_pool_<team_name>``. Tasks in DAG

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
creates a default pool named ``default_pool_<team_name>``. Tasks in DAG
creates a default pool named ``default_pool_<team_name>``. Tasks in Dag

@SameerMesiah97 SameerMesiah97 Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it not be DAG instead of Dag as it is an acronym?

Edit: Nvm, it appears that 'Dag' is the convention in the docs.


When ``core.multi_team`` is enabled, ``airflow teams create`` automatically
creates a default pool named ``default_pool_<team_name>``. Tasks in DAG
bundles associated with that team that do not explicitly specify a pool will

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bundles associated with that team that do not explicitly specify a pool will
bundles associated with that team which do not explicitly specify a pool will

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if 'which' is more gramatically correct than 'that' here as the part after is necessary for the sentence to communicate the complete idea. Regardless, I have rephrased this part for clarity.

bundles associated with that team that do not explicitly specify a pool will
use the team's default pool automatically.

Existing multi-team deployments should run ``airflow teams sync`` after upgrading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi-team is in experimental phase right now. I'm not sure we want to a very time based piece in our docs. Update the news fragment to call out this guidance about syncing existing multi-team deployments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread airflow-core/src/airflow/cli/commands/team_command.py Outdated
Comment thread airflow-core/src/airflow/cli/commands/team_command.py
Comment thread airflow-core/src/airflow/cli/commands/team_command.py Outdated
default_pool = session.scalar(select(Pool).where(Pool.pool == Pool.get_default_team_pool_name(team.name)))

if default_pool:
session.delete(default_pool)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This delete is happening way too soon. There is a check below "are you sure you want to delete..." you should not delete anything until after that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been moved down to the try/except block where team deletion is attempted.

Comment on lines +213 to +216
slots=conf.getint(
"core",
"default_pool_task_slot_count",
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clobbers any specific pool slots admins may have set if the pool already exists. You really just want create if missing not create or update

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are now querying for an existing default pool and creating it only if no pool is found.

Comment thread airflow-core/src/airflow/dag_processing/dagbag.py
with conf_vars(
{
("core", "multi_team"): "True",
("multi_team", "default_pool_task_slot_count"): "128",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
("multi_team", "default_pool_task_slot_count"): "128",
("core", "default_pool_task_slot_count"): "111",

This is a core config, and the default is already 128, setting it to something else ensures that this is working in your test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@SameerMesiah97
SameerMesiah97 force-pushed the Multi-Team-Default-Team-Pool branch 2 times, most recently from 6caec49 to 4ff010e Compare July 24, 2026 00:40
@SameerMesiah97
SameerMesiah97 marked this pull request as draft July 24, 2026 08:41
@SameerMesiah97
SameerMesiah97 force-pushed the Multi-Team-Default-Team-Pool branch from 4ff010e to c4de299 Compare July 24, 2026 19:03
Sameer Mesiah added 3 commits July 24, 2026 21:15
assign tasks without an explicit pool to the team's default pool during DAG
parsing. Add unit tests covering pool assignment and team creation, and
update the multi-team documentation to describe the new behaviour.
…missing pools for existing teams. Automatically remove the system-managed

default team pool during  while preserving protection for
user-created team pools. Add tests covering reconciliation and cleanup.
@SameerMesiah97
SameerMesiah97 force-pushed the Multi-Team-Default-Team-Pool branch from c4de299 to 88dc14b Compare July 24, 2026 20:16
Only create missing default team pools during teams sync,
improve cleanup during team deletion, and update the
documentation and tests.
@SameerMesiah97
SameerMesiah97 force-pushed the Multi-Team-Default-Team-Pool branch from 88dc14b to 1ca0fb1 Compare July 24, 2026 20:19
@SameerMesiah97
SameerMesiah97 marked this pull request as ready for review July 24, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi Team: Add team default pools for tasks

6 participants